

<html>
	<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="adminmain" />
        <title>SMF Administration - Content Management</title>
    </head>
    
    <body>
    		
        <div class="body">
        
            <h1>Success Story - Detail</h1>
            
            <g:if test="${flash.message}">
            	<div class="message">${flash.message}</div>
            </g:if>
            
            <div class="dialog">
                <table>
                   
					<tr class="prop">
						<td valign="top" class="name">Id:</td>
						<td valign="top" class="value">${story.id}</td>
						<td valign="top" class="value" rowspan="6">

							<table>
								<tr>
									<td>
										Default Picture:
										<g:if test="${story?.defaultPictureName == null}">
											<br><div class="message">no default image currently assigned to this story</div>
										</g:if>
										<g:else>
											<img src="/smf/images/${story.defaultPictureName}" style="max-width: 300px"/>
										</g:else>
									</td>
								</tr>
								<tr>
									<td>
										<g:form id="replaceStoryDefaultImage" method="post" action="replaceStoryDefaultImage" enctype="multipart/form-data">
											<input type="hidden" id="storyId" name="storyId" value="${story.id}"/>
											<input type="file" title="click 'browse', select an image (jpg or gif), and click the 'add' or 'replace' button" name="file"/>
											<g:if test="${story.defaultPictureName == null}">
												<input type="submit" value="add default image"/>
											</g:if>
											<g:else>
												<input type="submit" value="replace this image"/>
											</g:else>
										</g:form>
									</td>
								</tr>
								<g:if test="${story.defaultPictureName != null}">
									<tr>
										<td>
											<g:form id="deleteStoryDefaultImage" method="post" action="deleteStoryDefaultImage">
												<input type="hidden" id="storyId" name="storyId" value="${story.id}"/>
												<g:actionSubmit onclick="return confirm('are you sure you want to delete this image?');" 
																value="delete this image" />
											</g:form>
										</td>
									</tr>
								</g:if>
							</table>

						</td>
					</tr>

					<tr class="prop">
						<td valign="top" class="name">Title:</td>
						<td valign="top" class="value">${story.title}</td>
					</tr>

					<tr class="prop">
						<td valign="top" class="name">Video Url:</td>
						<td valign="top" class="value">${story.videoUrl.encodeAsHTML()}</td>
					</tr>

					<tr class="prop">
						<td valign="top" class="name">Enabled:</td>
						<td valign="top" class="value">${story.enabled}</td>
					</tr>

					<tr class="prop">
						<td valign="top" class="name">Date Created:</td>
						<td valign="top" class="value">${story.dateCreated}</td>
					</tr>

					<tr class="prop">
						<td valign="top" class="name">Introduction:</td>
						<td valign="top" class="value">${story.introduction}</td>
					</tr>

					<tr class="prop">
						<td valign="top" class="name">Body:</td>
						<td valign="top" class="value" colspan="3">${story.body}</td>
					</tr>

					<tr class="prop">
						<td valign="top" class="name">Additional Images:</td>
						
						<td valign="top" class="value" colspan="3">
							<table>
								<g:each var="storyImage" in="${story.storyImage}">
									<tr>
										<td>
											<g:form id="storyImageEditText" method="post" action="storyImageEditText">
												<input type="hidden" id="additionalImageId" name="additionalImageId" value="${storyImage.id}"/>
												<input type="submit" value="edit description"/>
											</g:form>
											
											<g:form id="deleteAdditionalImage" method="post" action="deleteAdditionalImage">
												<input type="hidden" id="additionalImageId" name="additionalImageId" value="${storyImage.id}"/>
												<input type="hidden" id="storyId" name="storyId" value="${story.id}"/>
												<g:actionSubmit onclick="return confirm('are you sure you want to delete this image?');" 
																value="delete this image" />
											</g:form>
										</td>
										<td>
											<img src="/smf/images/${storyImage.pictureName}" height="100"/>
										</td>
										<td>
											${storyImage.pictureDescription}
										</td>
									</tr>
								</g:each>
							</table>
						</td>
					</tr>
					
					<tr class="prop">
						<td valign="top" class="name">New Additional Image:</td>
						<td valign="top" class="value" colspan="3">
							<g:form id="uploadAdditionalStoryImage" method="post" action="uploadAdditionalStoryImage" enctype="multipart/form-data">
								<input type="hidden" id="storyId" name="storyId" value="${story.id}"/>
								<input type="file" name="file"/>
								<input type="submit" value="add image"/>
							</g:form>
						</td>
					</tr>

                </table>
                
            </div>
            
            <div class="buttons">
				<span class="menuButton">
					<g:link action="storyEdit" id="${story?.id}">Edit this Success Story</g:link>
				</span>
			</div>
			
        </div>
    </body>
</html>
